<template>
  <div class="add-address-page">
    <!-- 导航栏 -->
    <van-nav-bar
      title="添加地址"
      left-text="返回"
      @click-left="$router.push('/orderSubmit')"
    />
    <van-address-edit
      :area-list="areaList"
      show-postal
      ref="addressEdit"
      show-delete
      @save="handleSave"
      @delete="onDelete"
    />
  </div>
</template>

<script>
import {Toast} from 'vant';
import axios from "axios";
import {areaList} from "@vant/area-data";

export default {
  data() {
    return {
      areaList,
    };
  },
  methods: {
    handleSave(address) {
      console.log('保存地址操作', address);
      this.$router.push('/orderSubmit')
      //把数据传递到一个页面
      localStorage.setItem('address', JSON.stringify(address))
    },
    onDelete() {
      // 此处您可能还需要实现删除地址的逻辑
      Toast('删除地址操作');
    },
  },
  mounted() {

  }
};
</script>

<style scoped>
.add-address-page {
  padding: 10px;
}
</style>
